package com.qlm.jfinal;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.plugin.ehcache.EhCachePlugin;
import com.jfinal.render.ViewType;
import com.qlm.controller.AuthController;
import com.qlm.controller.AwardManageController;
import com.qlm.controller.CommentController;
import com.qlm.controller.CouponManageController;
import com.qlm.controller.GiftManageController;
import com.qlm.controller.HBManageController;
import com.qlm.controller.ImgManageController;
import com.qlm.controller.OrderController;
import com.qlm.controller.PrizesController;
import com.qlm.controller.RecordController;
import com.qlm.controller.ScanInfoController;
import com.qlm.controller.ScoreManageController;
import com.qlm.controller.UserController;
import com.qlm.controller.WXMenuController;
import com.qlm.entity.Admin;
import com.qlm.entity.Gift;
import com.qlm.entity.Img;
import com.qlm.entity.Order;
import com.qlm.log.LogerFactory;
import com.qlm.tongji.controller.StatisticController;
import com.qlm.tongji.controller.SummaryController;

public class JfinalConfig extends JFinalConfig {
	
	@Override
	public void configConstant(Constants me) {
		me.setDevMode(true);
		me.setViewType(ViewType.JSP);
		me.setLogFactory(new LogerFactory());
		PropKit.use("config.properties");
		me.setMaxPostSize(100*1024*1024);
	}

	@Override
	public void configHandler(Handlers me) {

	}

	@Override
	public void configInterceptor(Interceptors me) {

	}

	@Override
	public void configPlugin(Plugins me) {
		// 配置c3p0数据库连接池插件
		C3p0Plugin c3p0Plugin = new C3p0Plugin(PropKit.get("jdbcUrl"),
				PropKit.get("user"), PropKit.get("password").trim());
		me.add(c3p0Plugin);
		me.add(c3p0Plugin);
		// 配置ecache插件
		me.add(new EhCachePlugin());

		// 配置ActiveRecord插件
		ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
		me.add(arp);
		
		//实体类与数据库映射关系
		arp.addMapping("t_admin", Admin.class);
		arp.addMapping("t_gift", Gift.class);
		arp.addMapping("t_img", Img.class);//广告图片表
		arp.addMapping("t_order", Order.class);
		//arp.addMapping("t_wxmenu", WXMenu.class);

		arp.setShowSql(false);
		arp.setDevMode(true);
	}

	@Override
	public void configRoute(Routes me) {
		me.add("/",AuthController.class);
		me.add("/order", OrderController.class);
		me.add("/index", SummaryController.class);
		me.add("/statistics", StatisticController.class);
		me.add("/record", RecordController.class);
		me.add("/scanInfo", ScanInfoController.class);
		me.add("/couponManage",CouponManageController.class);
		me.add("/giftManage", GiftManageController.class);
		me.add("/awardManage",AwardManageController.class);
		me.add("/score",ScoreManageController.class);
		me.add("/img",ImgManageController.class);
		me.add("/hb",HBManageController.class);
		me.add("/yyy",PrizesController.class);
		me.add("/menu", WXMenuController.class);
		me.add("/comment",CommentController.class);
		me.add("/user",UserController.class);
	}

}
